<?php
 require_once("../test/php_connect.php");
 require_once("../lib/fonctions_requete_sql.php");
 require_once("../lib/tableau_association.php");

$connexion = new PDO('mysql:host='.$PARAM_hote.';dbname='.$PARAM_nom_bd, $PARAM_utilisateur, $PARAM_mot_passe,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));

$id= $_POST["matricule"];
$sql="SELECT * FROM prospect INNER JOIN etablissement ON etablissement.id_etablissement=usager.id_etablissement 
							INNER JOIN adresse ON adresse.id_adresse=etablissement.id_adresse
							INNER JOIN coordonnee ON etablissement.id_coordonnee=coordonnee.id_coordonnee
							INNER JOIN ville ON adresse.id_ville= ville.id_ville WHERE id_usager=$id";

$query = $connexion->query($sql);
foreach($query as $row)
	foreach($tab_correspondance_usager as $key=>$value)
		if($_POST[$key]!= $row[$value]){
			$requete = "UPDATE prospect SET $value = $_POST[$key] WHERE id_usager=$id";
			echo $requete;
			$req = $connexion->prepare($requete);
			$req->execute();
		}
	
?>